import cv2
import numpy as np

# 读取图像
img = cv2.imread('photo4.jpg')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

# 进行Shi - Tomasi角点检测
corners = cv2.goodFeaturesToTrack(gray, 25, 0.01, 10)

# 使用 np.intp 替代 np.int0
if corners is not None:
    corners = np.intp(corners)

    # 标记角点
    for i in corners:
        x, y = i.ravel()
        cv2.circle(img, (x, y), 3, 255, -1)

    # 显示结果
    cv2.imshow('Shi - Tomasi Corners', img)
    cv2.waitKey(0)
    cv2.destroyAllWindows()